package com.cn.wanxi.exception;

import com.cn.wanxi.entity.ResultEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理类
 */
@ControllerAdvice
public class BaseExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultEntity error(Exception e){
        e.printStackTrace();
        System.out.println("调用了公共异常处理类");
        return ResultEntity.failed(e.getMessage());
    }
}
